<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>5-倒计时跳转案例</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            line-height: 200px;
            text-align: center;
            font-size: 100px;
            font-weight: bold;
            border: 1px solid;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <div id="box">10</div>
    <script>
        let num=10
        let timeTD=setInterval(function(){
            //1.先判断 不是<1的数字 才可以显示 ,<1就结束
            if(num<1){
                clearInterval(timeTD)
                return
            }
            //2.显示
            box.innerHTML=num
            //3.显示玩 判断 如果是1，就跳转
            if(num==1){
                window.location.href="https://www.baidu.com"
            }
            num--
        },1000);
    </script>
</body>
</html>